﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class BM2 : BasePage
{

    string emId = string.Empty;
    string emYear = string.Empty;
    string emNum = string.Empty;
    string emRankName = string.Empty;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Count > 0)
        {
            emYear = Request.Params["EmYear"].Trim();
            emNum = Request.Params["EmNum"].Trim();
            emId = Request.Params["EmID"].ToString();
        }
        else
        {
            Response.Redirect(BSUtility.mainUrl + "default.aspx");
        }
        NoAccess.JumpToDefaultPageNoAccessTime(this, emId);
        
        DataTable dt_apply = Exam.getBMInfoByStudIdCard(IDCard, emId,emYear,emNum);
        if (dt_apply.Rows.Count > 0)
        {
            DataRow dr_apply = dt_apply.Rows[0];
            string applyState = dr_apply["ApplyState"].ToString();
            string orderId = dr_apply["OrderID"].ToString();
            if (applyState.Trim() == "1")
            {
                Response.Redirect(BSUtility.mainUrl + "BM/BM4.aspx?OrderID=" + orderId);
            }
            else if (applyState.Trim() == "2")
            {
                Response.Redirect(BSUtility.mainUrl + "BM/BM5.aspx?OrderID=" + orderId);
            }
        }


        if (!Page.IsPostBack)
        {
            DataTable dt = Exam.getRankNameByEmID(emId);
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow typeName in dt.Rows)
                {
                    ListItem liType = new ListItem(typeName["EmRankName"].ToString());
                    List_level.Items.Add(liType);
                }
            }
   
        }
    }


 
    protected void SInfoBtn_Insert_Click(object sender, EventArgs e)
    {
        emRankName = List_level.Text;
        if (!Exam.BMInfo_Save(IDCard, emYear, emNum, emId, emRankName))
        {
            //提示信息
        }
        else
        {

            Response.Redirect("BM3.aspx?EmYear=" + emYear + "&EmNum=" + emNum+"&EmID="+emId);
            //或者考试，次数 或者 报名号 ，身份证号
         
        }
        
    }

}